<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
</body>
<script>
  let tel = '010-12345678'
  //有010-或020-  \-为转义  \d{7,8}七位或八位连续整数
  console.log(/010\-\d{7,8}|020\-\d{7,8}/.test(tel)) //true
  console.log(/(010|020)\-\d{7,8}/.test(tel)) //true  与上面等价
  console.log(/[010|020]\-\d{7,8}/.test(tel)) //true  与上面等价
</script>
</html>